﻿///Write a program that extracts from given XML file all the text without the tags.
///Example:
/// <?xml version="1.0"?>
/// <student>
///    <name>Pesho</name>
///    <age>21</age>
///    <interests count="3">
///        <interest>Games</interest>
///        <interest>C#</interest>
///        <interest>Java</interest>
///    </interests>
/// </student>

// Regex.Matches(str, ">(.*?)<")
using System;
using System.IO;
using System.Text.RegularExpressions;


namespace c_sh_II_lek_6_files
{
    class zad10
    {
        static void Main()
        {

            string input = @"..\..\input.xml";
            string output = @"..\..\output.txt";

            using (StreamReader stream = new StreamReader(input))
            {
                using (StreamWriter _out = new StreamWriter(output))
                {
                    string line = stream.ReadLine();
                    while (line != null)
                    {
                        MatchCollection matchText = Regex.Matches(line, @">(.*?)<");
                        foreach (Match match in matchText)
                        {
                            string temp = match.ToString().Trim('<', '>');
                            Console.WriteLine( temp ); 
                             _out.WriteLine(temp);
                        }
                        
                        line = stream.ReadLine();
                    }
                }
            }

           
        }
    }
}
